const query = (function() {
    console.log(location.href);
    const query = {};
    /** 不需要分两步取值 */
    const search = /.*\?([^\?]+)/.exec(location.href)[1];
    /** 使用三元直接赋值 */
    const searchArr = search.indexOf("&") ? search.split("&") : search.split();

    searchArr.forEach((item) => {
        const queryArr = item.split("=");
        query[queryArr[0]] = queryArr[1];
    });

    return query;
})();
console.log(query);
fetch("http://chst.vip:1234/api/getbrand?brandtitleid=" + query.brandtitleid)
    .then(body => body.json())
    .then(res => {
        res.result.forEach(item => {
            if (item.brandId == query.brandid) {
                // console.log(item);
                nav_title.innerHTML = `<a href="?title=${query.title}&brandtitleid=${query.brandtitleid}&brandid=${query.brandid}">${item.brandName}></a>`
            }
            fetch("http://chst.vip:1234/api/getbrandproductlist?brandtitleid=" + query.brandtitleid)
                .then(body => body.json())
                .then(res => {
                    res.result.forEach(item2 => {
                        uu.innerHTML += `
                        <li>
                            <a href="productlist.html?categoryid=${item.categoryId}&productid=${item2.productId}&price=${/\d+/.exec(item2.productPrice)}" class="clearfix" data-product=${item2.productiId}>
                                <div class="img fl">${item2.productImg}</div>
                                <div class="infoR">
                                    <div class="title">
                                        <h4>${item2.productName}</h4>
                                        <div class="price">${item2.productPrice}</div>
                                    </div>
                                    <div class="other">
                                        <span class="take_price">${item2.productQuote}</span>
                                        <i class="talkabout">${item2.productCom}</i>
                                    </div>
                                </div>
                            </a>
                        </li>
                        `;
                    })
                })
        })
    })